/******************************************************************************
  Some simple Hisilicon Hi3516A system functions.

  Copyright (C), 2017-2018, Hisilicon Tech. Co., Ltd.
 ******************************************************************************
    Modification:  2018-1 Created
******************************************************************************/
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* End of #ifdef __cplusplus */

#include <stdio.h>
#include "hi_type.h"

#include "osal_mmz.h"

static HI_VOID BASE_exit(void)
{
    extern void base_mod_exit(void);
    base_mod_exit();
}

static HI_VOID MMZ_exit(void)
{
    extern void media_mem_exit(void);
    media_mem_exit();
#ifdef CONFIG_HI_TZASC_SUPPORT
    extern void tzasc_mod_exit(void);
    tzasc_mod_exit();
#endif
}
static HI_VOID SYS_exit(void)
{
    extern void sys_mod_exit(void);
    sys_mod_exit();
}

static HI_VOID ISP_exit(void)
{
    extern void isp_mod_exit(void);
    isp_mod_exit();
}

static HI_VOID VI_exit(void)
{
    extern void vi_mod_exit(void);
    vi_mod_exit();
}

static HI_VOID RGN_exit(void)
{
    extern void rgn_mod_exit(void);
    rgn_mod_exit();
}

static HI_VOID GDC_exit(void)
{
    extern void gdc_mod_exit(void);
    gdc_mod_exit();
}

static HI_VOID DIS_exit(void)
{
    extern void dis_mod_exit(void);
    dis_mod_exit();
}

#ifdef CONFIG_HI_MOTIONFUSION_SUPPORT
static HI_VOID Gyro_Dis_exit(void)
{
    extern void gyrodis_mod_exit(void);
    gyrodis_mod_exit();
}

static HI_VOID MOTIONFUSION_exit(void)
{
    extern void motionfusion_mod_exit(void);
    motionfusion_mod_exit();
}

static HI_S32 MotionSensorMng_exit(void)
{
    extern HI_S32 motionsensor_exit(HI_VOID);
    return motionsensor_exit();
}

static HI_S32 MotionSensorChipInit_exit(void)
{
    extern HI_S32 MotionSensorExit(void);
    return MotionSensorExit();
}
#endif

static HI_VOID VGS_exit(void)
{
    extern void vgs_mod_exit(void);
    vgs_mod_exit();
}

static HI_VOID VPSS_exit(void)
{
    extern void vpss_mod_exit(void);
    vpss_mod_exit();
}

static HI_VOID VO_exit(void)
{
    extern void vou_module_exit(void);
    vou_module_exit();
}

//NO tde&hifb on LiteOS
#if 0
static HI_S32 TDE_exit(void)
{
    return tde_mod_exit();
}

static HI_VOID HIFB_exit(void)
{
    extern HI_VOID hifb_cleanup(HI_VOID);

    hifb_cleanup();
}
#endif

static HI_VOID HDMI_exit(void)
{
    extern hi_void HDMI_DRV_ModExit(hi_void);
    HDMI_DRV_ModExit();
}

static HI_VOID MIPIRX_exit(void)
{
    extern void mipi_rx_mod_exit(void);
    mipi_rx_mod_exit();
}

static HI_VOID MIPITX_exit(void)
{
    extern void mipi_tx_module_exit(void);
    mipi_tx_module_exit();
}

static HI_VOID RC_exit(void)
{
    extern void rc_mod_exit(void);
    rc_mod_exit();
}

static HI_VOID VENC_exit(void)
{
    extern void venc_mod_exit(void);
    venc_mod_exit();
}

static HI_VOID CHNL_exit(void)
{
    extern void chnl_mod_exit(void);
    chnl_mod_exit();
}

static HI_VOID VEDU_exit(void)
{
    extern void vedu_mod_exit(void);
    vedu_mod_exit();
}

static HI_VOID H264e_exit(void)
{
    extern void h264e_mod_exit(void);
    h264e_mod_exit();
}

static HI_VOID H265e_exit(void)
{
    extern  void h265e_mod_exit(void);
    h265e_mod_exit();
}

static HI_VOID JPEGE_exit(void)
{
    extern void jpege_mod_exit(void);
    jpege_mod_exit();
}

static HI_VOID PWM_exit(void)
{
    extern void pwm_exit(void);
    pwm_exit();
}

static HI_VOID PIRIS_exit(void)
{
    extern void piris_exit(void);

    piris_exit();
}

static HI_S32 hi_sensor_spi_exit(void)
{
    return sensor_spi_dev_exit();
}

static HI_S32 hi_sensor_i2c_exit(void)
{
    extern void hi_dev_exit(void);
    hi_dev_exit();
}

static HI_S32 hi_sensor_serdes_exit(void)
{
    return serdes_mod_exit();
}

static HI_VOID JPEGD_exit(void)
{
    extern void jpegd_mod_exit(void);
    jpegd_mod_exit();
}

static HI_VOID VFMW_exit(void)
{
    extern void vfmw_mod_exit(void);
    vfmw_mod_exit();
}

static HI_VOID VDEC_exit(void)
{
    extern void vdec_mod_exit(void);
    vdec_mod_exit();
}

#ifdef CONFIG_HI_SVP_IVE
static void IVE_exit(void)
{
  extern void ive_mod_exit(void);
  ive_mod_exit();
}
#else
static void IVE_exit(void)
{
  return;
}
#endif

#ifdef CONFIG_HI_SVP_CNN
static void NNIE_exit(void)
{
  extern void nnie_mod_exit(void);
  nnie_mod_exit();
}
#else
static void NNIE_exit(void)
{
  return;
}
#endif

static void Cipher_exit(void)
{
    extern void cipher_drv_mod_exit(void);
    cipher_drv_mod_exit();
}

static void HI_USER_exit(void)
{
    extern void hi_user_exit(void);
    hi_user_exit();
}

#ifdef CONFIG_HI_PM_SUPPORT
static void PM_exit(void)
{
    extern void pm_module_exit(void);
    pm_module_exit();
}
#else
static void PM_exit(void)
{
    return ;
}
#endif

extern void osal_proc_exit(void);

HI_VOID SDK_exit(void)
{
    PM_exit();
#if CONFIG_HI_SUBCHIP_TYPE==HI3516C_V500
    Cipher_exit();
#endif
    MIPITX_exit();
    MIPIRX_exit();

    NNIE_exit();
    IVE_exit();
    JPEGD_exit();
    VFMW_exit();

    VDEC_exit();

    RC_exit();
    JPEGE_exit();
    H264e_exit();
    H265e_exit();
    VENC_exit();
    VEDU_exit();
    CHNL_exit();

    VO_exit();
    VPSS_exit();
    ISP_exit();
    VI_exit();
    GDC_exit();
    DIS_exit();
#ifdef CONFIG_HI_MOTIONFUSION_SUPPORT
    MotionSensorChipInit_exit();
    MotionSensorMng_exit();
    MOTIONFUSION_exit();
    Gyro_Dis_exit();
#endif
    VGS_exit();
    RGN_exit();

    HDMI_exit();
    hi_sensor_i2c_exit();
    hi_sensor_serdes_exit();
//    hi_sensor_spi_exit();
    PWM_exit();
    PIRIS_exit();

    SYS_exit();
    BASE_exit();
    MMZ_exit();
    osal_proc_exit();
    HI_USER_exit();
    printf("SDK exit ok...\n");
}


#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* End of #ifdef __cplusplus */


